package org.agile2soft.nexoma.core.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;

@Entity
@Table(name="SERVICE_OPTION",uniqueConstraints = @UniqueConstraint(columnNames = {"SER_ID","SEO_ID"}))
@SuppressWarnings("serial")
public class ServiceOption implements java.io.Serializable {

    private Integer id;
    private String name;
    private String url;
    private Service service;
    private Set<Profile> profiles = new HashSet<Profile>(0);

    public ServiceOption() {
    }

    public ServiceOption(String name, String url, Service service) {
        this.name = name;
        this.url= url;
        this.service = service;
    }

    public ServiceOption(String name, String url, Service service, Set<Profile>profiles) {
        this(name,url,service);
        this.profiles = profiles;
    }

    @Id
    @GeneratedValue(strategy=IDENTITY)
    @Column(name="SEO_ID",nullable=false,updatable=false)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name="SEO_NAME",unique=true,nullable=false,length=30)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name="SEO_URL",unique=true,nullable=true,length=200)
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SER_ID",nullable=false,updatable=true,insertable=true)
    public Service getService() {
        return this.service;
    }

    public void setService(Service service) {
        this.service=service;
    }

    @ManyToMany(fetch = FetchType.LAZY, mappedBy = "serviceOptions")
    public Set<Profile> getProfiles() {
        return this.profiles;
    }

    public void setProfiles(Set<Profile> profiles ) {
        this.profiles = profiles;
    }
}
